package com.library.entity.po;

import java.util.Objects;

/**
 * 学生借阅排行
 */
public class StudentRankPO implements Comparable<StudentRankPO> {

    private String sno;
    private String username;
    private Integer count;

    public StudentRankPO() {
    }

    public StudentRankPO(String sno, String username, Integer count) {
        this.sno = sno;
        this.username = username;
        this.count = count;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public String getSno() {
        return sno;
    }

    public void setSno(String sno) {
        this.sno = sno;
    }

    @Override
    public String toString() {
        return "StudentRankPO{" +
                "sno='" + sno + '\'' +
                ", username='" + username + '\'' +
                ", count=" + count +
                '}';
    }

    // 重写equals和hashCode方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        StudentRankPO studentRankPO = (StudentRankPO) o;
        return sno.equals(studentRankPO.sno);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sno);
    }

    @Override
    public int compareTo(StudentRankPO other) {
        int countCompare = Integer.compare(other.count, this.count);
        if (countCompare != 0) {
            return countCompare;
        }
        return this.sno.compareTo(other.sno);
    }

}
